import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import'
import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    styleImport({
          libs: [{
            libraryName: 'element-plus',
            esModule: true,
            ensureStyleFile: true,
            resolveStyle: (name) => {
              name = name.slice(3)
              return `element-plus/packages/theme-chalk/src/${name}.scss`;
            },
            resolveComponent: (name) => {
              return `element-plus/lib/${name}`;
            },
          }]
    }),
  ],
  alias: {
    '@': resolve(__dirname, 'src'),
    '@c': resolve(__dirname, 'src/components'),
    '@v': resolve(__dirname, 'src/views')
  },
  reslove: {
    // alias: {
    //   '/@': resolve(__dirname, 'src'),
    //   '/@c': resolve(__dirname, 'src/components'),
    //   '/@v': resolve(__dirname, 'src/views')
    // },
    extensins: [ '.js', '.ts', '.json']
  },
  server: {
    port: 3000,
    https: false,
    proxy: {
      '/api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        ws: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})
